package nhatquang.gs.controler;

import nhatquang.gs.model.BaseScene;
import nhatquang.gs.view.LevelScene;
import nhatquang.gs.view.MenuScene;
import nhatquang.gs.view.PlayerScene;
import nhatquang.gs.view.SplashScene;

import org.andengine.engine.Engine;
import org.andengine.ui.IGameInterface.OnCreateSceneCallback;

public class ScenesManager {
	public static final ScenesManager INSTAND = new ScenesManager();
	private Engine mEngine = ResourcesManager.getInstance().mEngine;
	public BaseScene mSplashScene, currentScene, mMenuScene, mPlayer;
	private OnCreateSceneCallback onCreateSceneCallback;
	private LevelScene mLevel;

	private void setScene(BaseScene scene) {
		mEngine.setScene(scene);
		currentScene = scene;
	}

	public static ScenesManager getInstance() {
		return INSTAND;
	}

	public BaseScene getCurrentScene() {
		return currentScene;
	}

	public void createSplashScene(OnCreateSceneCallback onCreateSceneCallback) {
		this.onCreateSceneCallback = onCreateSceneCallback;
		ResourcesManager.getInstance().loadSplash();
		mSplashScene = new SplashScene();
		ScenesManager.getInstance().setScene(mSplashScene);
		this.onCreateSceneCallback.onCreateSceneFinished(mSplashScene);
	}

	public void createMenu() {
		mMenuScene = new MenuScene();
		ScenesManager.getInstance().setScene(mMenuScene);
		onCreateSceneCallback.onCreateSceneFinished(mMenuScene);
	}

	public void loadMenuToPlayer() {
		mPlayer = new PlayerScene();
		ScenesManager.getInstance().setScene(mPlayer);
		onCreateSceneCallback.onCreateSceneFinished(mPlayer);
	}

	public void loadPlayerToMenu() {
		mMenuScene = new MenuScene();
		ScenesManager.getInstance().setScene(mMenuScene);
		onCreateSceneCallback.onCreateSceneFinished(mMenuScene);
	}

	public void loadMenuToLevel() {
		mLevel = new LevelScene();
		ScenesManager.getInstance().setScene(mLevel);
		onCreateSceneCallback.onCreateSceneFinished(mLevel);
	}

	public void loadLevelToMenu() {
		mMenuScene = new MenuScene();
		ScenesManager.INSTAND.setScene(mMenuScene);
		onCreateSceneCallback.onCreateSceneFinished(mMenuScene);
	}

	public void loadLeveltoPlayer(int level) {
		mPlayer = new PlayerScene();
		ScenesManager.getInstance().setScene(mPlayer);
		onCreateSceneCallback.onCreateSceneFinished(mPlayer);
	}

}
